package com.srs.backend.controller;


import com.srs.backend.service.OrderService;
import com.srs.backend.utils.Result;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;
import java.util.Objects;

@RestController
@RequestMapping("/api/order")
public class OrderController {
    @Resource
    private OrderService orderService;

    @PostMapping("/add/")
    public Result add(@RequestBody Map<String, String> data) {
        return orderService.add(data);
    }

    @PostMapping("/delete/")
    public Result delete(@RequestBody Map<String, String> data) {
        return orderService.delete(data);
    }

    @PostMapping("/modify/")
    public Result modify(@RequestBody Map<String, String> data) {
        return orderService.modify(data);
    }

    @PostMapping("/get/all/")
    public Result getAll() {
        return orderService.getAll();
    }

    @PostMapping("/add/order/and/items/")
    public Result addOrderAndItem(@RequestBody Map<String, Object> data) {
        return orderService.addOrderAndItems(data);
    }

    @PostMapping("/get/order/by/client/id/")
    public Result getAllByClientId(@RequestBody Map<String, String> data) {
        return orderService.getAllByClientId(data);
    }
    @PostMapping("/check/out/")
    public Result checkOut(@RequestBody Map<String, String> data) {
        return orderService.checkOut(data);
    }
    @PostMapping("/get/total/money/by/period/")
    public Result getTotalMoneyByPeriod(@RequestBody Map<String, String> data) {
        return orderService.getTotalMoneyByPeriod(data);
    }
    @PostMapping("/get/all/unpaid/orders/")
    public Result getAllUnpaidOrders() {
        return orderService.getAllUnpaidOrders();
    }
}
